﻿<UserControl x:Class="CBR.Views.HomeView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:Controls="clr-namespace:CBR.Components.Controls"
             xmlns:Converters="clr-namespace:CBR.Components.Converters"
             xmlns:model="clr-namespace:CBR.ViewModels"
             mc:Ignorable="d"
			 Background="{DynamicResource CbrDarkBackgroundBrush}"
             d:DesignHeight="400" d:DesignWidth="600">

    <UserControl.Resources>

        <DataTemplate x:Key="HeadlineTemplate" DataType="{x:Type model:Headline}">
			<Grid Margin="6" Cursor="Hand" Background="Transparent">
                <StackPanel Margin="3" >
                    <StackPanel Orientation="Horizontal">
                        <Image Width="32" Source="{Binding Path=ImageUri}" />
						<TextBlock Style="{DynamicResource CbrTextBlock}" TextTrimming="WordEllipsis" Text="{Binding Title}" />
                    </StackPanel>
					<TextBlock Style="{DynamicResource CbrTextBlockSmall}" FontStyle="Italic" TextTrimming="None" TextWrapping="WrapWithOverflow"
                                Text="{Binding Description}" />
                </StackPanel>
            </Grid>

        </DataTemplate>

		<!--<Style TargetType="{x:Type ItemsControl}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ItemsControl}">
						<ScrollViewer VerticalScrollBarVisibility="Auto">
							<ItemsPresenter />
						</ScrollViewer>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>-->

    </UserControl.Resources>

	<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="90" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Image Source="/CBR;component/Resources/Images/book128.png" Margin="10" />
            <StackPanel Grid.Column="1" Orientation="Vertical">
				<TextBlock Text="Comic Book Reader" HorizontalAlignment="Left" Margin="5,5,0,0" Style="{DynamicResource CbrTitleLabel}" />
				<TextBlock HorizontalAlignment="Left" Margin="5,0,0,5" Style="{DynamicResource CbrSubTitleLabel}"
					   Text="{LocalizationExtension ResModul=CBR, Key=HomeView.LblSlogan, DefaultValue=The new standard to manage and read your eBooks !}" />
            </StackPanel>
        </Grid>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="2*" />
            </Grid.ColumnDefinitions>

            <StackPanel Grid.Column="0" Margin="10">
				<TextBlock Style="{DynamicResource CbrSubTitleLabel}" Margin="5"
                       Text="{LocalizationExtension ResModul=CBR, Key=HomeView.LblActions, DefaultValue=Quick Actions}" />
	            <Line Style="{DynamicResource CbrDashedSeparator}" X1="0" X2="1" />
				<StackPanel Margin="10,0,10,0" Orientation="Vertical">
					<Button Style="{DynamicResource CbrStandardButton}" Margin="2,10,2,10"
							Command="{Binding ForwardCommand}" CommandParameter="CatalogNewCommand" >
                        <DockPanel Margin="10">
                            <Image Source="/CBR;component/Resources/Images/32x32/library_new.png" Width="32"></Image>
                            <Label Style="{DynamicResource CbrLabel}"
                                   Content="{LocalizationExtension ResModul=CBR, Key=HomeView.LblActionNew, DefaultValue=Start a new library}" />
                        </DockPanel>
                    </Button>
					<Button Style="{DynamicResource CbrStandardButton}" Margin="2,10,2,10"
							Command="{Binding ForwardCommand}" CommandParameter="BookOpenCommand" >
                        <DockPanel Margin="10">
                            <Image Source="/CBR;component/Resources/Images/32x32/book/book_read.png" Width="32"></Image>
							<Label Style="{DynamicResource CbrLabel}"
                                   Content="{LocalizationExtension ResModul=CBR, Key=HomeView.LblActionRead, DefaultValue=Read a book}" />
                        </DockPanel>
                    </Button>
					<Button Style="{DynamicResource CbrStandardButton}" Margin="2,10,2,10"
							Command="{Binding ForwardCommand}" CommandParameter="SysHelpCommand">
                        <DockPanel Margin="10">
							<Image Source="/CBR;component/Resources/Images/32x32/book_type/book_type_xps.png" Width="32"></Image>
							<Label Style="{DynamicResource CbrLabel}"
                                   Content ="{LocalizationExtension ResModul=CBR, Key=HomeView.LblActionTutorial, DefaultValue=Quick start tutorial}" />
                        </DockPanel>
                    </Button>
				</StackPanel>
			</StackPanel>
			
            <Line Grid.Column="1" X1="0" Y2="1" Style="{DynamicResource CbrVerticalSeparator}" />

            <Grid Grid.Column="2" Margin="10">
                <StackPanel>
                    <TextBlock Style="{DynamicResource CbrSubTitleLabel}" Margin="5"
                       Text="{LocalizationExtension ResModul=CBR, Key=HomeView.LblRssFeed, DefaultValue=Headlines}" />
                    <Line Style="{DynamicResource CbrDashedSeparator}" X1="0" X2="1" />
                </StackPanel>
                <Grid Margin="0,50,0,0">
                    <ListBox Name="RssViewer" Style="{DynamicResource CbrStandardListBox}"
							HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0"
							Visibility="{Binding HasError, Converter={x:Static Converters:InversedBoolToVisibilityConverter.Instance}}"
							ItemsSource="{Binding ItemsSource}"
							ItemTemplate="{StaticResource HeadlineTemplate}" MouseUp="RssViewer_MouseUp" />

                    <Image Visibility="{Binding HasError, Converter={x:Static Converters:BoolToVisibilityConverter.Instance}}" 
                           Source="/CBR;component/Resources/Images/32x32/icon/forbidden.png" Stretch="None" />
                    <Controls:WaitSpin AutoPlay="False" IsPlaying="{Binding IsLoading}" AssociatedElement="{Binding ElementName=RssViewer}"/>
                </Grid>

            </Grid>

        </Grid>

		<StackPanel Grid.Row="2" >
			<Line Style="{DynamicResource CbrDashedSeparator}" X1="0" X2="1" VerticalAlignment="Top" />
			<WrapPanel VerticalAlignment="Center" HorizontalAlignment="Stretch" >
				<TextBlock Style="{DynamicResource CbrTextBlockSmall}" Margin="10,2,2,2"
                   Text="{LocalizationExtension ResModul=CBR, Key=HomeView.LblAuthor, DefaultValue=Author:}" />
				<TextBlock Style="{DynamicResource CbrTextBlockSmall}">G.Waser</TextBlock>
				<TextBlock Style="{DynamicResource CbrTextBlockSmall}" Margin="10,2,2,2"
                   Text="{LocalizationExtension ResModul=CBR, Key=HomeView.LblCopyRight, DefaultValue=- Copyright:}" />
				<TextBlock Style="{DynamicResource CbrTextBlockSmall}">2011</TextBlock>
				<TextBlock Style="{DynamicResource CbrTextBlockSmall}" Margin="10,2,2,2"
                   Text="{LocalizationExtension ResModul=CBR, Key=HomeView.LblVersion, DefaultValue=- Version:}" />
				<TextBlock Style="{DynamicResource CbrTextBlockSmall}" Text="{Binding ApplicationVersion}" />
				<TextBlock Style="{DynamicResource CbrTextBlockSmall}" Margin="10,2,2,2"
                   Text="{LocalizationExtension ResModul=CBR, Key=HomeView.LblWebSite, DefaultValue=- Web site:}" />
				<Label>
					<Hyperlink NavigateUri="http://wfpbookreader.codeplex.com/" RequestNavigate="Hyperlink_RequestNavigate">Codeplex</Hyperlink>
				</Label>
			</WrapPanel>
		</StackPanel>
    </Grid>
</UserControl>
